home *** CD-ROM | disk | FTP | other *** search
/ Introduction to 3D Game …ogramming with DirectX 12 / Introduction-to-3D-Game-Programming-with-DirectX-12.ISO / Code.Textures / Chapter 7 Drawing in Direct3D Part II / Shapes / Shaders / color.hlsl
Encoding:
Text File  |  2016-03-02  |  1.2 KB  |  62 lines

  1. //***************************************************************************************
  2. // color.hlsl by Frank Luna (C) 2015 All Rights Reserved.
  3. //
  4. // Transforms and colors geometry.
  5. //***************************************************************************************
  6.  
  7. cbuffer cbPerObject : register(b0)
  8. {
  9.     float4x4 gWorld; 
  10. };
  11.  
  12. cbuffer cbPass : register(b1)
  13. {
  14.     float4x4 gView;
  15.     float4x4 gInvView;
  16.     float4x4 gProj;
  17.     float4x4 gInvProj;
  18.     float4x4 gViewProj;
  19.     float4x4 gInvViewProj;
  20.     float3 gEyePosW;
  21.     float cbPerObjectPad1;
  22.     float2 gRenderTargetSize;
  23.     float2 gInvRenderTargetSize;
  24.     float gNearZ;
  25.     float gFarZ;
  26.     float gTotalTime;
  27.     float gDeltaTime;
  28. };
  29.  
  30. struct VertexIn
  31. {
  32.     float3 PosL  : POSITION;
  33.     float4 Color : COLOR;
  34. };
  35.  
  36. struct VertexOut
  37. {
  38.     float4 PosH  : SV_POSITION;
  39.     float4 Color : COLOR;
  40. };
  41.  
  42. VertexOut VS(VertexIn vin)
  43. {
  44.     VertexOut vout;
  45.     
  46.     // Transform to homogeneous clip space.
  47.     float4 posW = mul(float4(vin.PosL, 1.0f), gWorld);
  48.     vout.PosH = mul(posW, gViewProj);
  49.     
  50.     // Just pass vertex color into the pixel shader.
  51.     vout.Color = vin.Color;
  52.     
  53.     return vout;
  54. }
  55.  
  56. float4 PS(VertexOut pin) : SV_Target
  57. {
  58.     return pin.Color;
  59. }
  60.  
  61.  
  62.